package com.xbs.controller.hitchhiking;

import java.io.IOException;
import java.sql.Date;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.xbs.controller.base.BaseServlet;
import com.xbs.entity.HitchEntity;
import com.xbs.entity.OrderMoney;
import com.xbs.service.hitchhiking.HitchOrderService;
import com.xbs.service.hitchhiking.HitchService;
@WebServlet("/hitchhiking/orderfinish")
public class OrderFinishServlet extends BaseServlet{
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
	HitchOrderService htichorder = new HitchOrderService();

	String uname = (String) req.getSession().getAttribute("uname");
	String uidcard = (String) req.getSession().getAttribute("uidcard");
	String uemail = (String) req.getSession().getAttribute("uemail");
	String orderid = (String) req.getSession().getAttribute("orderid");
	String paytime = (String) req.getSession().getAttribute("paytime");
	String gettime = (String) req.getSession().getAttribute("gettime");
	String returntime = (String) req.getSession().getAttribute("returntime");
	String costutas = "已付款";
	String hitchtype = (String) req.getSession().getAttribute("hitchtype");
	String startdoor = (String) req.getSession().getAttribute("startdoor");
	String enddoor = (String) req.getSession().getAttribute("enddoor");
	
	/**
	 * 1.获取车辆信息
	 */
	HitchService hitchservie = new HitchService();
	List<HitchEntity> orderlst = hitchservie.getCarToOrder(hitchtype,startdoor,enddoor);
	HitchEntity hitch= orderlst.get(0);
	
	/**
	 * 2.向数据库插入信息
	 */
	HitchOrderService horderservice = new HitchOrderService();
	int row = horderservice.getHitchOrder(hitch, uname, uidcard, uemail, orderid,costutas);
	int row2 = horderservice.getHitchTime(gettime, returntime, orderid, paytime);
	int row3 = horderservice.getHitchRent("zhazha", uname, uidcard, uemail, orderid);
	OrderMoney om = new OrderMoney();
	om.setOrder_id(orderid);
	int row4 = horderservice.getOrderMoney(om);
	//转发		
	forward("businessview/llp_order/payfinish");
}
}
